﻿#ifndef __RACE__H__
#define __RACE__H__
#include "fixed64.h"
class Race
{
public:
	Race();
	virtual ~Race();

	bool load_navmesh_from_file(const char* pcFileName);
	bool load_navmesh_from_buffer(unsigned char* buf, int length);
	bool load_geom(const char* pcFileName);
	bool load_mesh(unsigned char* buf, int length);
	bool load_geom_setting(unsigned char* buf, int length);

	void update(FPRaw dt);

	//interface for render
	const fixed64* get_mesh_verts(int& vcnt) const;
	const int* get_mesh_triangles(int& tcnt) const;
	inline const class dtNavMesh* get_mesh(void) const { return mNavMesh; }
	inline const class dtTileCache* get_tilecache(void) const { return mTileCache; }

	void removeAgent(const int idx);

	int addAgent(const fixed64* pos);
	void getAgentPos(int idx, fixed64* pos);

	bool randomPos(fixed64* pos);

	bool initCrowd(const int maxAgents, const fixed64 maxAgentRadius);

	bool Race::agentMovePos(int idx, const fixed64* pos);

	bool Race::agentMoveVelocity(int idx, const fixed64* pos);

	bool Race::addTempObstacle(fixed64 radius, fixed64 height, const fixed64* pos, int* ref);

	bool Race::removeTempObstacle(int ref);

	bool Race::stopAgentMove(int idx);

	bool Race::setAgentPos(int idx, fixed64* pos);


private:
	class dtNavMesh* mNavMesh;
	struct LinearAllocator* m_talloc;
	struct FastLZCompressor* m_tcomp;
	struct MeshProcess* m_tmproc;
	class dtTileCache* mTileCache;
	class InputGeom* mGeom;
	class dtCrowd* m_crowd;
    class dtQueryFilter* m_filter;
	struct dtCrowdAgentDebugInfo* m_agentDebug;
	class dtObstacleAvoidanceDebugData* m_vod;
};
#endif//__RACE__H__